package com.yzy.soft.system.freemarker.template;

import com.yzy.soft.system.freemarker.*;
import com.yzy.soft.system.freemarker.database.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class TemplateDao extends TemplateKernel {

    private final static Logger logger=LoggerFactory.getLogger(TemplateDao.class);

    @Override
    public File generateFileType(FileInfo fileInfo,Table table, DBInfo dbInfo) throws Exception {
//        final String suffix = "DAO.java";
        JavaFileDao javaFile=((JavaFile)fileInfo).getJavaFileDao();
        String tableName = StringUtil.replaceUnderLineAndUpperCase(table.getTableName());
        final String path = fileInfo.getDiskPath() + tableName + javaFile.getSuffix();
        System.out.println("TemplateDao path:"+path);
        final String templateName = "DAO.ftl";
        File mapperFile = new File(path);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        generateFileByTemplate(templateName, mapperFile,fileInfo, dataMap);
        return mapperFile;
    }




}
